const Koa = require("koa");
const app = new Koa();
const koa_json = require("koa-json");
const { koaBody } = require("koa-body");
const koa_logger = require("koa-logger");
const router = require('koa-router')();

const user = require('./routers/user.js');

app.use(async (ctx, next) => {
    try {
        await next();
    } catch (err) {
        console.log(err)
        ctx.body = "boom";
    }
});

app.use(koaBody());
app.use(koa_json());
app.use(koa_logger());

app.use(user.routes());

app.use(router.allowedMethods());

app.listen(3333);